<?php echo $header; ?>
<!--
<div id="scroller_container">
<marquee style="background-color:#ffffff;padding:10px 0px 5px 10px;font-size:26px;" behavior="scroll" scrollAmount="3" width="100%" height="30" onMouseOver="this.scrollAmount=1" onMouseOut="this.scrollAmount=3">
<a href="http://katerprom.ru/index.php?route=product/category&path=67" target="_parent" style="font-size:26px;">Финские катера 2012 года новые в упаковке и на гарантии по старым спец. ценам!</a>
&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://katerprom.ru/index.php?route=information/information&information_id=7" target="_parent" style="font-size:26px;"><strong>Все катера в кредит!</strong></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://katerprom.ru/index.php?route=information/information&information_id=4" target="_parent" style="font-size:26px;">Доставка по всей России!</a>
</marquee>  
</div>
-->
<div id="scroller_container">
<a href="/index.php?route=information/contact"><input type="button" value="Задать вопрос"></a>
</div>
<?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
  <!--div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <br>
  <h1><?php echo $heading_title; ?></h1-->
  <?php if ($thumb || $description) { ?>
  <div class="category-info">
    <?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
    <?php } ?>
    <?php if ($description) { ?>
    <?php echo $description; ?>
    <?php } ?>
  </div>
  <?php } ?>

  <?php if ($products) { ?>
  <!--div class="product-filter">
    <div class="display"><b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display('grid');"><?php echo $text_grid; ?></a></div>
    <div class="limit"><b><?php echo $text_limit; ?></b>
      <select onchange="location = this.value;">
        <?php foreach ($limits as $limits) { ?>
        <?php if ($limits['value'] == $limit) { ?>
        <option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
    <div class="sort"><b><?php echo $text_sort; ?></b>
      <select onchange="location = this.value;">
        <?php foreach ($sorts as $sorts) { ?>
        <?php if ($sorts['value'] == $sort . '-' . $order) { ?>
        <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
        <?php } else { ?>
        <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
        <?php } ?>
        <?php } ?>
      </select>
    </div>
  </div-->
  <!--div class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div-->
  <div class="product-list">
     <?php
     
						function sdf_array_sorting_asc($a,$b){
							if ((float)$a['_fafa'] == (float)$b['_fafa']) { return 0; };
							if ((float)$a['_fafa'] > (float)$b['_fafa']) { return -1; };
							return 1;// если a>b
						}

						function sdf_array_sorting_key($array, $key)
						// Выполняет: сортировку многомерного массива по ключу
						// Возвращает: отсортированный массив
						{
						// делаем копию массива для преобразований
							$r=$array;

							// разбираем многомерный массив на части
							foreach($r as &$v) { $v['_fafa']=$v[$key]; }

							// сортируем массив через пользовательскую функцию sdf_array_sorting_asc
							usort($r, 'sdf_array_sorting_asc');

							// собираем обратно массив
							foreach ($r as &$v) { unset($v['_fafa']); }

							// возвращаем результат
							return $r;
						}// /sdf_array_sorting_key
     
      
		if($_GET['path'] == "67"){
						$product_one = array();
						$product_two = array();
						$product_three = array();
				
						//var_dump($products);
				
						foreach ($products as $product) { 
				 
							if($product['model']  == 'Buster') array_push($product_one, $product);
							if($product['model']  == 'Flipper') array_push($product_two, $product);
							if($product['model']  == 'Bella') array_push($product_three, $product);
						}
							

						$product_one = sdf_array_sorting_key($product_one, 'price');
						$product_two = sdf_array_sorting_key($product_two, 'price');
						$product_three = sdf_array_sorting_key($product_three, 'price');

						//$product_one = sdf_array_sorting_key($product_one, 'weight');
						//$product_two = sdf_array_sorting_key($product_two, 'weight');
						//$product_three = sdf_array_sorting_key($product_three, 'weight');



						echo '<table border="0" width="1150px">';
							echo '<tr><td><a href="/index.php?route=product/category&path=67_72"><img src="/Buster.jpg" /></a></td><td><a href="/index.php?route=product/category&path=62_73"><img src="/flipper.jpg" /></a><td><a href="/index.php?route=product/category&path=62_74"><img src="/bella.jpg" /></a></td></td></tr>';
							
							
								for($i=0; $i < max(count($product_one), count($product_two), count($product_three)); $i++){	
										echo "<tr>";
										echo "<td>";	
											if($i < count($product_one)){
												
												?>
												<div class="image"><a href="<?php echo $product_one[$i]['href']; ?>"><img src="<?php echo $product_one[$i]['thumb']; ?>" title="<?php echo $product_one[$i]['name']; ?>" alt="<?php echo $product_one[$i]['name']; ?>" /></a></div>
												<?php
												echo '<div><a href="'.$product_one[$i]['href'].'">'.$product_one[$i]['name'].'</a></div>';
												echo '<div style="font-size: 20px">';
												if($product_one[$i]['product_id'] == '69'){
													echo '2013 год - '.number_format($product_one[$i]['price'], 0, ',', ' ' ).' рублей<br>';
													echo '<span style="color: red">2012 год -  1 739 000 рублей</span>';
												}else{?>	
														<?php if (!$product_one[$i]['special']) { ?>
														<?php echo number_format( $product_one[$i]['price'], 0, ',', ' ' ); ?> рублей
														<?php } else { ?>
														<span class="price-old"><?php echo $product_one[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_one[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
														<?php } ?>
												</div>
												<?php
												};
											}else{
												echo "&nbsp;";
											};
										echo "</td>";
										echo "<td>";	
											if($i < count($product_two)){
												
												?>
												<div class="image"><a href="<?php echo $product_two[$i]['href']; ?>"><img src="<?php echo $product_two[$i]['thumb']; ?>" title="<?php echo $product_one[$i]['name']; ?>" alt="<?php echo $product_two[$i]['name']; ?>" /></a></div>
												<?php
												echo '<div><a href="'.$product_two[$i]['href'].'">'.$product_two[$i]['name'].'</a></div>';
												echo '<div style="font-size: 20px">';?>
												<?php if (!$product_two[$i]['special']) { ?>
												<?php echo number_format( $product_two[$i]['price'], 0, ',', ' ' ); ?> рублей
												<?php } else { ?>
												<span class="price-old"><?php echo $product_two[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_two[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
												<?php } ?>
												</div>
												<?php					
											}else{
												echo "&nbsp;";
											};
										echo "</td>";
										echo "<td>";	
											if($i < count($product_three)){
												?>
												<div class="image"><a href="<?php echo $product_three[$i]['href']; ?>"><img src="<?php echo $product_three[$i]['thumb']; ?>" title="<?php echo $product_one[$i]['name']; ?>" alt="<?php echo $product_three[$i]['name']; ?>" /></a></div>
											   <?php
												echo '<div><a href="'.$product_three[$i]['href'].'">'.$product_three[$i]['name'].'</a></div>';
												echo '<div style="font-size: 20px">';?>
												<?php if (!$product_three[$i]['special']) { ?>
												<?php echo number_format( $product_three[$i]['price'], 0, ',', ' ' ); ?> рублей
												<?php } else { 
																if($product_three[$i]['special'] == '1 рублей'){
															    echo number_format( $product_three[$i]['price'], 0, ',', ' ' ); ?> 	
																
																рублей <span style="color: red">АКЦИЯ</span>
																<?php	
																}else{?>
												<span class="price-old"><?php echo $product_three[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_three[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
												<?php }} ?>
												</div>
												<?php
											}else{
												echo "&nbsp;";
											};
										echo "</td>";
										echo "</tr>";
								}
								echo "</table>"; 
		}elseif($_GET['path'] == "66"){
											$product_one = array();
											$product_two = array();
											$product_three = array();
									
											//var_dump($products);
									
											foreach ($products as $product) { 
									 
												if($product['model']  == 'Vector') array_push($product_one, $product);
												if($product['model']  == 'Respo') array_push($product_two, $product);
												if($product['model']  == 'Skif') array_push($product_three, $product);
											}
												
											
											//$product_one = sdf_array_sorting_key($product_one, 'price');
											//$product_two = sdf_array_sorting_key($product_two, 'price');
											//$product_three = sdf_array_sorting_key($product_three, 'price');

											$product_one = sdf_array_sorting_key($product_one, 'weight');
											$product_two = sdf_array_sorting_key($product_two, 'weight');
											$product_three = sdf_array_sorting_key($product_three, 'weight');



											echo '<table border="0" width="1150px">';
												echo '<tr><td><a href="/index.php?route=product/category&amp;path=66_77"><img src="/vektor.jpg" /></a></td><td><a href="/index.php?route=product/category&amp;path=66_75"><img src="/respo.jpg" /></a><td><a href="/index.php?route=product/category&amp;path=66_78"><img src="/skif.png" /></a></td></td></tr>';
												
													for($i=0; $i < max(count($product_one), count($product_two), count($product_three)); $i++){	
															echo "<tr>";
															echo "<td>";	
																if($i < count($product_one)){
																	
																	?>
																	<div class="image"><a href="<?php echo $product_one[$i]['href']; ?>"><img src="<?php echo $product_one[$i]['thumb']; ?>" title="<?php echo $product_one[$i]['name']; ?>" alt="<?php echo $product_one[$i]['name']; ?>" /></a></div>
																	<?php
																	echo '<div><a href="'.$product_one[$i]['href'].'">'.$product_one[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_one[$i]['special']) { ?>
																	<?php echo number_format( $product_one[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_one[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_one[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	echo 'Грузоподъемность: '.number_format($product_one[$i]['weight'], 0,'.',' ').' кг';																	
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "<td>";	
																if($i < count($product_two)){
																	
																	?>
																	<div class="image"><a href="<?php echo $product_two[$i]['href']; ?>"><img src="<?php echo $product_two[$i]['thumb']; ?>" title="<?php echo $product_two[$i]['name']; ?>" alt="<?php echo $product_two[$i]['name']; ?>" /></a></div>
																	<?php
																	echo '<div><a href="'.$product_two[$i]['href'].'">'.$product_two[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_two[$i]['special']) { ?>
																	<?php echo number_format( $product_two[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_two[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_two[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	echo 'Грузоподъемность: '.number_format($product_two[$i]['weight'], 0,'.',' ').' кг';					
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "<td>";	
																if($i < count($product_three)){
																	?>
																	<div class="image"><a href="<?php echo $product_three[$i]['href']; ?>"><img src="<?php echo $product_three[$i]['thumb']; ?>" title="<?php echo $product_three[$i]['name']; ?>" alt="<?php echo $product_three[$i]['name']; ?>" /></a></div>
																   <?php
																	echo '<div><a href="'.$product_three[$i]['href'].'">'.$product_three[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_three[$i]['special']) { ?>
																	<?php echo number_format( $product_three[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_three[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_three[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	echo 'Грузоподъемность: '.number_format($product_three[$i]['weight'], 0,'.',' ').' кг';
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "</tr>";
													}
													echo "</table>"; 
							
		}elseif($_GET['path'] == "62"){
											$product_one = array();
											$product_two = array();
											$product_three = array();
									
											//var_dump($products);
									
											foreach ($products as $product) { 
									 
												if($product['model']  == 'Mercury') array_push($product_one, $product);
												if($product['model']  == 'Suzuki') array_push($product_two, $product);
												if($product['model']  == 'Yamaha') array_push($product_three, $product);
											}
												
											//$product_one = sdf_array_sorting_key($product_one, 'price');
											//$product_two = sdf_array_sorting_key($product_two, 'price');
											//$product_three = sdf_array_sorting_key($product_three, 'price');

											$product_one = sdf_array_sorting_key($product_one, 'weight');
											$product_two = sdf_array_sorting_key($product_two, 'weight');
											$product_three = sdf_array_sorting_key($product_three, 'weight');



											echo '<table border="0" width="1150px">';
												echo '<tr><td><a href="/index.php?route=product/category&path=62_69"><img src="/Mercury.jpg" /></a></td><td><a href="/index.php?route=product/category&path=62_71"><img src="/suzuki.jpg" /></a><td><a href="/index.php?route=product/category&path=62_70"><img src="/yamaha.jpg" /></a></td></td></tr>';
												
													for($i=0; $i < max(count($product_one), count($product_two), count($product_three)); $i++){	
															echo "<tr>";
															echo "<td>";	
																if($i < count($product_one)){
																	
																	?>
																	<div class="image"><a href="<?php echo $product_one[$i]['href']; ?>"><img src="<?php echo $product_one[$i]['thumb']; ?>" title="<?php echo $product_one[$i]['name']; ?>" alt="<?php echo $product_one[$i]['name']; ?>" /></a></div>
																	<?php
																	echo '<div><a href="'.$product_one[$i]['href'].'">'.$product_one[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_one[$i]['special']) { ?>
																	<?php echo number_format( $product_one[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_one[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_one[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	print rtrim(rtrim($product_one[$i]['weight'], '0'), '.').' л.с';																
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "<td>";	
																if($i < count($product_two)){
																	
																	?>
																	<div class="image"><a href="<?php echo $product_two[$i]['href']; ?>"><img src="<?php echo $product_two[$i]['thumb']; ?>" title="<?php echo $product_two[$i]['name']; ?>" alt="<?php echo $product_two[$i]['name']; ?>" /></a></div>
																	<?php
																	echo '<div><a href="'.$product_two[$i]['href'].'">'.$product_two[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_two[$i]['special']) { ?>
																	<?php echo number_format( $product_two[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_two[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_two[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	print rtrim(rtrim($product_two[$i]['weight'], '0'), '.').' л.с';			
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "<td>";	
																if($i < count($product_three)){
																	?>
																	<div class="image"><a href="<?php echo $product_three[$i]['href']; ?>"><img src="<?php echo $product_three[$i]['thumb']; ?>" title="<?php echo $product_three[$i]['name']; ?>" alt="<?php echo $product_three[$i]['name']; ?>" /></a></div>
																   <?php
																	echo '<div><a href="'.$product_three[$i]['href'].'">'.$product_three[$i]['name'].'</a></div>';
																	echo '<div style="font-size: 20px">';?>
																	<?php if (!$product_three[$i]['special']) { ?>
																	<?php echo number_format( $product_three[$i]['price'], 0, ',', ' ' ); ?> рублей
																	<?php } else { ?>
																	<span class="price-old"><?php echo $product_three[$i]['price']; ?></span> <span class="price-new"><?php echo number_format( $product_three[$i]['special'], 0, ',', ' ' ).' рублей'; ?></span>
																	<?php } ?>
																	</div>
																	<?php
																	print rtrim(rtrim($product_three[$i]['weight'], '0'), '.').' л.с';
																}else{
																	echo "&nbsp;";
																};
															echo "</td>";
															echo "</tr>";
													}
													echo "</table>"; 
							
		}else{ 
			//Сортируем все остальные товары по цене
			$products = sdf_array_sorting_key($products, 'price');
			
				/*
				echo "<pre>";
					var_dump($products);
				echo "</pre>";
				*/ 
			?>
			<?php foreach ($products as $product) { 
					
			?>
				<div>
					<?php if ($product['thumb']) { ?>
						<div class="image"><a href="<?php echo $product['href']; ?>"><img width="300" src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
					<?php } ?>
					<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
					<div class="description"></div>
					<?php if ($product['price']!=0) { ?>
							<div class="price">
					<?php if (!$product['special']) { ?>
						<?php echo number_format( $product['price'], 0, ',', ' ' ); ?> рублей
					<?php } else { ?>
						<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
					<?php }
					// Получить id продукта (режим разработки)
					//echo '<br>'.$product['product_id'];
					?>
                    <div>
						<?php
							if($product['product_id'] == 372){
							  echo '<span style="color: red">Хит продаж</span>'; 
							}
						?>
					</div>
					</div>
					<?php } ?>
					<?php if ($product['rating']) { ?>
						<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
					<?php } ?>
					<div class="cart">
						<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" style="display:none;"/>
					</div>
					<div class="wishlist"></div>
					<div class="compare"></div>
				</div>
	<?php } ?>
		<?php }
    ?>
  </div>
  <div class="pagination"><?php echo $pagination; ?></div>
  <?php } ?>
  <?php if (!$categories && !$products) { ?>
  <div class="content"><?php echo $text_empty; ?></div>
  <div class="buttons">
    <div class="right"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
  </div>
  <?php } ?>
  <?php echo $content_bottom; ?></div>
<script type="text/javascript"><!--
function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			html += '  <div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '  <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '  <div class="compare">' + $(element).find('.compare').html() + '</div>';
			html += '</div>';			
			
			html += '<div class="left">';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
					
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
				
			html += '</div>';

						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
		$.cookie('display', 'list'); 
	} else {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
						
			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
		$.cookie('display', 'grid');
	}
}

view = $.cookie('display');

if (view) {
	display('grid');
} else {
	display('grid');
}
//--></script> 
<?php echo $footer; ?>
